(function(){
	/**
	 * 背景类
	 */
	
	class Background {
		constructor(params){
			this.image = params.image;
			this.width = params.width;
			this.height = params.height;
			this.y = params.y;
			this.x = 0;
			this.speed = params.speed;

			this.amount = parseInt(game.canvas.width / this.width) + 1;
		}


		update(){

			this.x-=this.speed;
			if(this.x < -this.width * this.amount){
				this.x = 0;
			}
		}

		render(){
			for(let i = 0; i < this.amount * 2; i++){
				game.ctx.drawImage(this.image,0,0,this.width,this.height,this.x + this.width * i,this.y,this.width,this.height);
			}

		}
	}


	window.Background = Background;
})();
